package com.demo.servlet.demo1208;

import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/demo05.do")
public class Demo05Servlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //解决响应的中文乱码
        response.setContentType("text/html;charset=UTF-8");
        //获取响应对象的 字符输出流
        PrintWriter writer = response.getWriter();
        writer.write("<h1>您好，您是第几个登录网站的人！</h1>");
        //获取响应对象的 字节输出流
        ServletOutputStream outputStream = response.getOutputStream();
        outputStream.write("你好".getBytes());
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

    }
}
